package com.ruoyi.web.controller.travel;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import javax.xml.transform.Result;

import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.travel.domain.TravelOrder;
import com.ruoyi.travel.service.ITravelOrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

@RestController
@RequestMapping("/travel/order")
public class TravelOrderController extends BaseController {
    @Autowired
    private ITravelOrderService travelOrderService;
    /**
     * 查询订单管理列表
     */
    @PreAuthorize("@ss.hasPermi('travel:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(TravelOrder travelOrder) {
        startPage();
        List<TravelOrder> list = travelOrderService.selectTravelOrderList(travelOrder);
        return getDataTable(list);

    }

    /**
     * 获取订单管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('travel:order:query')")
    @GetMapping(value = "/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId") Long orderId) {
        return success(travelOrderService.selectTravelOrderByOrderId(orderId));
    }

    /**
     * 新增订单管理
     */
    @PreAuthorize("@ss.hasPermi('travel:order:add')")
    @Log(title = "订单管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TravelOrder travelOrder) {
        return toAjax(travelOrderService.insertTravelOrder(travelOrder));
    }

    /**
     * 修改订单管理
     */
    @PreAuthorize("@ss.hasPermi('travel:order:edit')")
    @Log(title = "订单管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TravelOrder travelOrder) {
        return toAjax(travelOrderService.updateTravelOrder(travelOrder));
    }

    /**
     * 删除订单管理
     */
    @PreAuthorize("@ss.hasPermi('travel:order:remove')")
    @Log(title = "订单管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{orderIds}")
    public AjaxResult remove(@PathVariable Long[] orderIds) {
        return toAjax(travelOrderService.deleteTravelOrderByOrderIds(orderIds));
    }


}







